package com.recruit.common.util;
import com.recruit.model.result.PositionResultDO;

import java.util.HashMap;
import java.util.Map;
/**
 * @author 陈竞超
 * @version 1.0
 * @qq 2250537249
 */
public class PositionResultDOConverter {
    public static Map<String, Object> positionConvert(PositionResultDO positionResultDO) {
        Map<String, Object> jobData = new HashMap<>();

        // 职位名称
        jobData.put("职位名称", positionResultDO.getTitle());

        // 职位分类
        jobData.put("职位分类", positionResultDO.getCategoryName());

        // 应聘人数
        jobData.put("应聘人数", positionResultDO.getQuantity());

        // 薪资（处理空值）
        Integer salaryDown = positionResultDO.getSalaryDown();
        Integer salaryUp = positionResultDO.getSalaryUp();
        String salary;
        if (salaryDown != null && salaryUp != null) {
            salary = salaryDown + "-" + salaryUp;
        } else if (salaryDown != null) {
            salary = salaryDown.toString();
        } else if (salaryUp != null) {
            salary = "至" + salaryUp;
        } else {
            salary = "";
        }
        jobData.put("薪资", salary);

        // 工作地点
        jobData.put("工作地点", positionResultDO.getCity());

        // 栏位要求
        jobData.put("栏位要求", positionResultDO.getRequirement());

        return jobData;
    }

    // 示例用法
//    public static void main(String[] args) {
//        PositionResultDO example = new PositionResultDO();
//        example.setTitle("Java开发工程师");
//        example.setCategoryName("技术类");
//        example.setQuantity(5);
//        example.setSalaryDown(10000);
//        example.setSalaryUp(20000);
//        example.setCity("北京");
//        example.setRequirement("需要Java经验，熟悉Spring框架");
//        Map<String, Object> jobData = convert(example);
//        System.out.println(jobData);
//    }
}
